package com.sds.shop.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import com.sds.fw.dao.AbDao;
import com.sds.shop.vo.CategoryVO;
import com.sds.shop.vo.PaymentVO;

public class PaymentDAO extends AbDao {

	private static PaymentDAO pDao = new PaymentDAO();
	public static PaymentDAO getInstance(){
		return pDao;
	}
	
	public ArrayList<PaymentVO> getPaymentList(){
		ArrayList<PaymentVO> list = new ArrayList<PaymentVO>();
		Connection conn = null;
		PreparedStatement ps = null;
		ResultSet rs = null;
		try{
			conn = connect();
			
			StringBuffer query = new StringBuffer();
			query.append("SELECT pay_no, ord_no, payment_opt_cd, pay_amt, pay_dtm FROM tb_payment ");
			
			ps = conn.prepareStatement( query.toString() );

			rs = ps.executeQuery();
			while(rs.next()){
				PaymentVO pvo = new PaymentVO();
			    pvo.setPayNo(rs.getString(1));
			    pvo.setOrgNo(rs.getString(2));
			    pvo.setPaymentOptCd(rs.getString(3));
			    pvo.setPayAtm(rs.getInt(4));
			    pvo.setDtm(rs.getString(5));
				list.add(pvo);
			}
			close(conn, ps, rs);
		}catch(Exception ex){
			System.out.println("getCategoryList exception : " + ex);
			close(conn, ps, rs);
		}
		
		return list;
	} // getPaymentsList
	

}
